﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
//using System.Linq;
using System.Text;
using System.Windows.Forms;
using RainmeterCustomized.VariablesClass;

namespace RainmeterCustomized
{
    public partial class MyPictureBox : PanelExtend
    {
        public MyPictureBox(Image img)
        {
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            BackColor = Color.Transparent;
            this.Image = img;
            this.Width = img.Width;
            this.Height = img.Height;
        }
        public MyPictureBox()
        {
            this.Image = Properties.Resources.ali;
        }

        private Image img;
        public Image Image
        {
            set { this.img = value; }
            get { return this.img; }
        }


        protected override void OnDraw()
        {
            Image img = this.Image;
            int width = img.Size.Width;
            int height = img.Size.Height;
            Rectangle rect = new Rectangle(0, 0, width, height);
            this.graphics.DrawImage(img, rect);
        }


        private Dictionary<String, String> actionList = new Dictionary<String, String>();
        
        private String imagePath;

        public String ImagePath
        {
            set { this.imagePath = value; }
            get { return this.imagePath; }
        }

        /// <summary>
        /// 在实际屏幕中的真实坐标
        /// </summary>
        private Point relLocation;
        public Point RelLocation
        {
            set { this.relLocation = value; }
            get { return this.relLocation; }
        }

        public Dictionary<String, String> GetActionList()
        {
            return this.actionList;
        }
        public Boolean AddAction(String actionName, String action)
        {
            try
            {
                if (actionList.ContainsKey(actionName))
                {
                    actionList[actionName] = action;
                }
                else
                {
                    actionList.Add(actionName, action);
                }
                return true;
            }
            catch
            {
                return false;
            }
        }

    }
}
